//#include "epwm_driver.h"
//
//EPWMINFO_T epwm1Info;
//EPWMINFO_T epwm2Info;
//EPWMINFO_T epwm3Info;
//EPWMINFO_T epwm4Info;
//
//void USER_InitEPWM(void)
//{
//    //
//    // Interrupts that are used in this example are re-mapped to
//    // ISR functions found within this file.
//    //
//    Interrupt_register(INT_EPWM1, &epwm1ISR);
//    Interrupt_register(INT_EPWM2, &epwm2ISR);
//    Interrupt_register(INT_EPWM3, &epwm3ISR);
//    Interrupt_register(INT_EPWM4, &epwm4ISR);
//    //
//    // Disable sync(Freeze clock to PWM as well)
//    //
//    //SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
////    initEPWM1();
////    initEPWM2();
////    initEPWM3();
//
//
//    //
//    // Enable sync and clock to PWM
//    //
//
//    SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
//    initEPWMWithoutDB(myEPWM1_BASE,EPWM1_TIMER_TBPRD,&epwm1Info);
//    initEPWMWithoutDB(myEPWM2_BASE,EPWM2_TIMER_TBPRD,&epwm2Info);
//    initEPWMWithoutDB(myEPWM3_BASE,EPWM3_TIMER_TBPRD,&epwm3Info);
//    initEPWMWithoutDB(myEPWM4_BASE,EPWM4_TIMER_TBPRD,&epwm4Info);
//    SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
//
//    //
//    // Enable interrupts required for this example
//    //
//    Interrupt_enable(INT_EPWM1);
//    Interrupt_enable(INT_EPWM2);
//    Interrupt_enable(INT_EPWM3);
//    Interrupt_enable(INT_EPWM4);
//
//
//}
////
//// epwm1ISR - EPWM1 ISR to update compare values
////
//__interrupt void epwm1ISR(void)
//{
//    //
//    // Update the CMPA and CMPB values
//    //
//    updateCompare(&epwm1Info);
//
//    //
//    // Clear INT flag for this timer
//    //
//    EPWM_clearEventTriggerInterruptFlag(myEPWM1_BASE);
//
//    //
//    // Acknowledge this interrupt to receive more interrupts from group 3
//    //
//    Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP3);
//}
//
////
//// epwm2ISR - EPWM2 ISR to update compare values
////
//__interrupt void epwm2ISR(void)
//{
//    //
//    // Update the CMPA and CMPB values
//    //
//    updateCompare(&epwm2Info);
//
//    //
//    // Clear INT flag for this timer
//    //
//    EPWM_clearEventTriggerInterruptFlag(myEPWM2_BASE);
//
//    //
//    // Acknowledge this interrupt to receive more interrupts from group 3
//    //
//    Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP3);
//}
//
////
//// epwm3ISR - EPWM3 ISR to update compare values
////
//__interrupt void epwm3ISR(void)
//{
//    //
//    // Update the CMPA and CMPB values
//    //
//    updateCompare(&epwm3Info);
//
//    //
//    // Clear INT flag for this timer
//    //
//    EPWM_clearEventTriggerInterruptFlag(myEPWM3_BASE);
//
//    //
//    // Acknowledge this interrupt to receive more interrupts from group 3
//    //
//    Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP3);
//}
//
////
//// epwm4ISR - EPWM3 ISR to update compare values
////
//__interrupt void epwm4ISR(void)
//{
//    //
//    // Update the CMPA and CMPB values
//    //
//    updateCompare(&epwm4Info);
//
//    //
//    // Clear INT flag for this timer
//    //
//    EPWM_clearEventTriggerInterruptFlag(myEPWM4_BASE);
//
//    //
//    // Acknowledge this interrupt to receive more interrupts from group 3
//    //
//    Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP3);
//}
//
//void setupEPWMOutputSwap(uint16_t base)
//{
//
//    //
//    // Disable RED
//    //
//    EPWM_setDeadBandDelayMode(base, EPWM_DB_RED, false);
//
//    //
//    // Disable FED
//    //
//    EPWM_setDeadBandDelayMode(base, EPWM_DB_FED, false);
//
//    //
//    // Switch Output A with Output B
//    //
//    EPWM_setDeadBandOutputSwapMode(base, EPWM_DB_OUTPUT_A, true);
//    EPWM_setDeadBandOutputSwapMode(base, EPWM_DB_OUTPUT_B, true);
//
//}
//
//void setupEPWMActiveHigh(uint16_t base)
//{
//    //
//    // Use EPWMA as the input for both RED and FED
//    //
//    EPWM_setRisingEdgeDeadBandDelayInput(base, EPWM_DB_INPUT_EPWMA);
//    EPWM_setFallingEdgeDeadBandDelayInput(base, EPWM_DB_INPUT_EPWMA);
//
//    //
//    // Set the RED and FED values
//    //
//    EPWM_setFallingEdgeDelayCount(base, EPWM_FED_VAL);
//    EPWM_setRisingEdgeDelayCount(base, EPWM_RED_VAL);
//
//
//    //
//    // Do not invert the delayed outputs (AH)
//    //
//    EPWM_setDeadBandDelayPolarity(base, EPWM_DB_RED, EPWM_DB_POLARITY_ACTIVE_HIGH);
//    EPWM_setDeadBandDelayPolarity(base, EPWM_DB_FED, EPWM_DB_POLARITY_ACTIVE_HIGH);
//
//    //
//    // Use the delayed signals instead of the original signals
//    //
//    EPWM_setDeadBandDelayMode(base, EPWM_DB_RED, true);
//    EPWM_setDeadBandDelayMode(base, EPWM_DB_FED, true);
//
//    //
//    // DO NOT Switch Output A with Output B
//    //
//    EPWM_setDeadBandOutputSwapMode(base, EPWM_DB_OUTPUT_A, false);
//    EPWM_setDeadBandOutputSwapMode(base, EPWM_DB_OUTPUT_B, false);
//
//}
//
//void setupEPWMActiveLowComplementary(uint16_t base)
//{
//    //
//    // Use EPWMA as the input for both RED and FED
//    //
//    EPWM_setRisingEdgeDeadBandDelayInput(base, EPWM_DB_INPUT_EPWMA);
//    EPWM_setFallingEdgeDeadBandDelayInput(base, EPWM_DB_INPUT_EPWMA);
//
//    //
//    // Set the RED and FED values
//    //
//    EPWM_setFallingEdgeDelayCount(base, EPWM_FED_VAL);
//    EPWM_setRisingEdgeDelayCount(base, EPWM_RED_VAL);
//
//    //
//    // Invert only the Rising Edge delayed output (ALC)
//    //
//    EPWM_setDeadBandDelayPolarity(base, EPWM_DB_RED, EPWM_DB_POLARITY_ACTIVE_LOW);
//    EPWM_setDeadBandDelayPolarity(base, EPWM_DB_FED, EPWM_DB_POLARITY_ACTIVE_HIGH);
//
//    //
//    // Use the delayed signals instead of the original signals
//    //
//    EPWM_setDeadBandDelayMode(base, EPWM_DB_RED, true);
//    EPWM_setDeadBandDelayMode(base, EPWM_DB_FED, true);
//
//    //
//    // DO NOT Switch Output A with Output B
//    //
//    EPWM_setDeadBandOutputSwapMode(base, EPWM_DB_OUTPUT_A, false);
//    EPWM_setDeadBandOutputSwapMode(base, EPWM_DB_OUTPUT_B, false);
//
//}
//
//
//void setupEPWMActiveHighComplementary(uint16_t base)
//{
//    //
//    // Use EPWMA as the input for both RED and FED
//    //
//    EPWM_setRisingEdgeDeadBandDelayInput(base, EPWM_DB_INPUT_EPWMA);
//    EPWM_setFallingEdgeDeadBandDelayInput(base, EPWM_DB_INPUT_EPWMA);
//
//    //
//    // Set the RED and FED values
//    //
//    EPWM_setFallingEdgeDelayCount(base, EPWM_FED_VAL);
//    EPWM_setRisingEdgeDelayCount(base, EPWM_RED_VAL);
//
//    //
//    // Invert only the Falling Edge delayed output (AHC)
//    //
//    EPWM_setDeadBandDelayPolarity(base, EPWM_DB_RED, EPWM_DB_POLARITY_ACTIVE_HIGH);
//    EPWM_setDeadBandDelayPolarity(base, EPWM_DB_FED, EPWM_DB_POLARITY_ACTIVE_LOW);
//
//    //
//    // Use the delayed signals instead of the original signals
//    //
//    EPWM_setDeadBandDelayMode(base, EPWM_DB_RED, true);
//    EPWM_setDeadBandDelayMode(base, EPWM_DB_FED, true);
//
//    //
//    // DO NOT Switch Output A with Output B
//    //
//    EPWM_setDeadBandOutputSwapMode(base, EPWM_DB_OUTPUT_A, false);
//    EPWM_setDeadBandOutputSwapMode(base, EPWM_DB_OUTPUT_B, false);
//
//}
//
//
//
//void setupEPWMActiveLow(uint16_t base)
//{
//    //
//    // Use EPWMA as the input for both RED and FED
//    //
//    EPWM_setRisingEdgeDeadBandDelayInput(base, EPWM_DB_INPUT_EPWMA);
//    EPWM_setFallingEdgeDeadBandDelayInput(base, EPWM_DB_INPUT_EPWMB);
//
//    //
//    // Set the RED and FED values
//    //
//    EPWM_setFallingEdgeDelayCount(base, EPWM_FED_VAL);
//    EPWM_setRisingEdgeDelayCount(base, EPWM_RED_VAL);
//
//    //
//    // INVERT the delayed outputs (AL)
//    //
//    EPWM_setDeadBandDelayPolarity(base, EPWM_DB_RED, EPWM_DB_POLARITY_ACTIVE_LOW);
//    EPWM_setDeadBandDelayPolarity(base, EPWM_DB_FED, EPWM_DB_POLARITY_ACTIVE_LOW);
//
//    //
//    // Use the delayed signals instead of the original signals
//    //
//    EPWM_setDeadBandDelayMode(base, EPWM_DB_RED, true);
//    EPWM_setDeadBandDelayMode(base, EPWM_DB_FED, true);
//
//    //
//    // DO NOT Switch Output A with Output B
//    //
//    EPWM_setDeadBandOutputSwapMode(base, EPWM_DB_OUTPUT_A, false);
//    EPWM_setDeadBandOutputSwapMode(base, EPWM_DB_OUTPUT_B, false);
//
//}
//
//
////
//// initEPWM - Configure ePWM1
////
//void initEPWMWithoutDB(uint16_t base,uint16_t EPWM_TIMER_TBPRD,EPWMINFO_T* epwmInfo)
//{
//    //
//    // Set-up TBCLK
//    //
//    EPWM_setTimeBasePeriod(base, EPWM_TIMER_TBPRD);
//    EPWM_setPhaseShift(base, 0U);
//    EPWM_setTimeBaseCounter(base, 0U);
//    EPWM_setTimeBaseCounterMode(base, EPWM_COUNTER_MODE_UP_DOWN);
//
//
//    //
//    // Set ePWM clock pre-scaler
//    //
////    EPWM_setClockPrescaler(base,
////                           EPWM_CLOCK_DIVIDER_2,
////                           EPWM_HSCLOCK_DIVIDER_2);
//
//    //
//    // Set up shadowing
//    //
//    EPWM_setCounterCompareShadowLoadMode(base,
//                                         EPWM_COUNTER_COMPARE_A,
//                                         EPWM_COMP_LOAD_ON_CNTR_ZERO);
//
//    //
//    // Set-up compare
//    //
//    EPWM_setCounterCompareValue(base, EPWM_COUNTER_COMPARE_A, EPWM_TBPRD_INITVAL);
//    EPWM_setCounterCompareValue(base, EPWM_COUNTER_COMPARE_B, EPWM_TBPRD_INITVAL);
//
//    //
//    // Set actions
//    //
//    EPWM_setActionQualifierAction(base,
//                                      EPWM_AQ_OUTPUT_A,
//                                      EPWM_AQ_OUTPUT_LOW,
//                                      EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO);
//    EPWM_setActionQualifierAction(base,
//                                      EPWM_AQ_OUTPUT_A,
//                                      EPWM_AQ_OUTPUT_HIGH,
//                                      EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
//    EPWM_setActionQualifierAction(base,
//                                      EPWM_AQ_OUTPUT_A,
//                                      EPWM_AQ_OUTPUT_NO_CHANGE,
//                                      EPWM_AQ_OUTPUT_ON_TIMEBASE_PERIOD);
//    EPWM_setActionQualifierAction(base,
//                                      EPWM_AQ_OUTPUT_A,
//                                      EPWM_AQ_OUTPUT_LOW,
//                                      EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA);
//
//
//    EPWM_setActionQualifierAction(base,
//                                      EPWM_AQ_OUTPUT_B,
//                                      EPWM_AQ_OUTPUT_LOW,
//                                      EPWM_AQ_OUTPUT_ON_TIMEBASE_ZERO);
//    EPWM_setActionQualifierAction(base,
//                                      EPWM_AQ_OUTPUT_B,
//                                      EPWM_AQ_OUTPUT_HIGH,
//                                      EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPB);
//    EPWM_setActionQualifierAction(base,
//                                      EPWM_AQ_OUTPUT_B,
//                                      EPWM_AQ_OUTPUT_NO_CHANGE,
//                                      EPWM_AQ_OUTPUT_ON_TIMEBASE_PERIOD);
//    EPWM_setActionQualifierAction(base,
//                                      EPWM_AQ_OUTPUT_B,
//                                      EPWM_AQ_OUTPUT_LOW,
//                                      EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPB);
//
//    epwmInfo->base=base;
//    epwmInfo->epwmTimerTbprd=EPWM_TIMER_TBPRD;
//    epwmInfo->cmpa_val=EPWM_TBPRD_INITVAL;
//    epwmInfo->cmpb_val=EPWM_TBPRD_INITVAL;
//    epwmInfo->getDutyCyclePerc=500;
//
//    EPWM_setInterruptSource(base, EPWM_INT_TBCTR_ZERO);
//    EPWM_enableInterrupt(base);
//    EPWM_setInterruptEventCount(base, 4U);
//    EPWM_enablePhaseShiftLoad(base);
//}
//
//void updateCompare(EPWMINFO_T *epwmInfo)
//{
//    uint32_t dutyCycleVal;
//    uint32_t permille=TBPRD_MAX_VAL;
//    uint32_t temp;
//    temp= ((uint32_t)(epwmInfo->setDutyCyclePerc)*(uint32_t)(epwmInfo->epwmTimerTbprd));
//    dutyCycleVal=temp/permille;
//
//    if(dutyCycleVal>=epwmInfo->epwmTimerTbprd)
//    {
//        dutyCycleVal=epwmInfo->epwmTimerTbprd;
//    }
//    EPWM_setCounterCompareValue(epwmInfo->base,EPWM_COUNTER_COMPARE_A,dutyCycleVal);
//    //EPWM_setCounterCompareValue(epwmInfo->base,EPWM_COUNTER_COMPARE_B,dutyCycleVal);
//    EPWM_setCounterCompareValue(epwmInfo->base,EPWM_COUNTER_COMPARE_B,epwmInfo->epwmTimerTbprd - dutyCycleVal);
//}
//
//void setEpwmDutyCycle(uint16_t base,uint16_t dutyCyclePerc)
//{
//    switch(base)
//    {
//        case myEPWM1_BASE:
//                epwm1Info.setDutyCyclePerc=dutyCyclePerc;
//                break;
//        case myEPWM2_BASE:
//                epwm2Info.setDutyCyclePerc=dutyCyclePerc;
//                break;
//        case myEPWM3_BASE:
//                epwm3Info.setDutyCyclePerc=dutyCyclePerc;
//                break;
//        case myEPWM4_BASE:
//                epwm4Info.setDutyCyclePerc=dutyCyclePerc;
//                break;
//        default:
//                return;
//    }
//}
////
//// End of file
////
